<?php
// 测试用户照片
try {
    $host = '113.44.136.17';
    $port = '3306';
    $database = 'qiandao';
    $username = 'qiandao';
    $password = 'NGbks3HWx5PhSxDX';
    $charset = 'utf8mb4';

    $dsn = "mysql:host={$host};port={$port};dbname={$database};charset={$charset}";
    $pdo = new PDO($dsn, $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    echo "=== 检查用户照片路径 ===\n";
    $stmt = $pdo->query("SELECT id, name, img FROM checkin_member WHERE status = 1 LIMIT 1");
    $user = $stmt->fetch(PDO::FETCH_ASSOC);
    
    if ($user) {
        echo "用户: {$user['name']}, 照片路径: {$user['img']}\n";
        
        // 检查本地文件
        $imgUrl = $user['img'];
        if (strpos($imgUrl, 'http') === 0) {
            $localPath = str_replace('http://192.168.8.140:8000/', __DIR__ . '/public/', $imgUrl);
            echo "本地路径: $localPath\n";
            
            if (file_exists($localPath)) {
                $fileSize = filesize($localPath);
                echo "文件存在，大小: $fileSize bytes\n";
                
                // 检查图片信息
                $imageInfo = getimagesize($localPath);
                if ($imageInfo) {
                    echo "图片尺寸: {$imageInfo[0]} x {$imageInfo[1]}\n";
                    echo "图片类型: {$imageInfo['mime']}\n";
                    
                    // 生成base64并检查大小
                    $base64 = base64_encode(file_get_contents($localPath));
                    echo "Base64大小: " . strlen($base64) . " 字符\n";
                    echo "Base64前50字符: " . substr($base64, 0, 50) . "...\n";
                } else {
                    echo "无法读取图片信息，可能不是有效的图片文件\n";
                }
            } else {
                echo "本地文件不存在\n";
            }
        }
    }
    
} catch (Exception $e) {
    echo "错误: " . $e->getMessage() . "\n";
}
